﻿<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace="Nullable" 
xmlns="http://ibatis.apache.org/mapping" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <alias>
    <typeAlias alias="Nullable" type="MyBatis.DataMapper.Sqlite.Test.Domain.NullableClass, MyBatis.DataMapper.Sqlite.Test"/>
  </alias>

  <resultMaps>

    <resultMap id="Nullable-result-constructor"  class="Nullable" >
      <constructor>
        <argument argumentName="id"		 column="TestInt32"/>
      </constructor>
      <result property="Id" column="Id"/>
      <result property="TestBool" column="TestBool" />
      <result property="TestByte" column="TestByte" />
      <result property="TestChar" column="TestChar" />
      <result property="TestDateTime" column="TestDateTime" />
      <result property="TestDecimal" column="TestDecimal" />
      <result property="TestDouble" column="TestDouble" />
      <result property="TestGuid" column="TestGuid"/>
      <result property="TestInt16" column="TestInt16"/>
      <result property="TestInt64" column="TestInt64"/>
      <result property="TestSingle" column="TestSingle" />
    </resultMap>
    
    <resultMap id="Nullable-result" class="Nullable">
      <result property="Id" column="Id"/>
      <result property="TestBool" column="TestBool" />
      <result property="TestByte" column="TestByte" />
      <result property="TestChar" column="TestChar" />
      <result property="TestDateTime" column="TestDateTime" />
      <result property="TestDecimal" column="TestDecimal" />
      <result property="TestDouble" column="TestDouble" />
      <result property="TestGuid" column="TestGuid"/>
      <result property="TestInt16" column="TestInt16"/>
      <result property="TestInt32" column="TestInt32"/>
      <result property="TestInt64" column="TestInt64"/>
      <result property="TestSingle" column="TestSingle" />
      <result property="TestTimeSpan" column="TestTimeSpan" />
    </resultMap>
  </resultMaps >

  <statements>

    <select id="GetNullableConstructor" resultMap="Nullable-result-constructor" >
      select
      *
      from Nullable
      where Id = #value#
    </select>
    
    <select id="GetNullable" resultMap="Nullable-result" >
      select
        *
      from Nullable
      where Id = #value#
    </select>


    <select id="GetClassNullable" resultClass="Nullable" >
      select
      *
      from Nullable
      where Id = #value#
    </select>
    
    <insert id="InsertNullable" parameterClass="Nullable" >
      <selectKey property="Id" type="post" resultClass="int">
        select SCOPE_IDENTITY() as value
      </selectKey>
      insert into Nullable
      (TestBool, TestByte, TestChar, TestDateTime, TestDecimal, TestDouble, TestGuid, TestInt16, TestInt32, TestInt64, TestSingle, TestTimeSpan)
      values
      (#TestBool#, #TestByte#, #TestChar#, #TestDateTime#, #TestDecimal#, #TestDouble#, #TestGuid#, #TestInt16#, #TestInt32#, #TestInt64#, #TestSingle#, #TestTimeSpan#)
    </insert>
    
  </statements>
</sqlMap>
